package com.shizhanzhe.gxb.vip;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.crazysunj.cardslideview.CardHandler;
import com.crazysunj.cardslideview.CardViewPager;
import com.shizhanzhe.gxb.R;
import com.shizhanzhe.gxb.base.UserBean;
import com.shizhanzhe.gxb.url.Path;
import com.shizhanzhe.gxb.utils.Util;
import com.shizhanzhe.gxb.vip.bean.MyBean;

/**
 * description
 * <p>
 * Created by sunjian on 2017/6/24.
 */

public class MyCardHandler implements CardHandler<MyBean> {

    @Override
    public View onBind(final Context context, final MyBean data, final int position, @CardViewPager.TransformerMode int mode) {
        View view = View.inflate(context, R.layout.item, null);
        ImageView imageView = (ImageView) view.findViewById(R.id.image);
        ImageView ewm = (ImageView) view.findViewById(R.id.iv_ewm);
//        ImageView head = (ImageView) view.findViewById(R.id.iv_head);
//        TextView nc = (TextView) view.findViewById(R.id.tv_nc);
//        TextView userid = (TextView) view.findViewById(R.id.userid);
//        if (!"".equals(UserBean.nickname)) {
//            nc.setText(UserBean.nickname);
//        } else {
//            nc.setText("新用户");
//        }
//        userid.setText("   ID:"+UserBean.uid+"   ");
//        ElasticCardView cardView = (ElasticCardView) view.findViewById(R.id.cardview);
//        final boolean isCard = mode == CardViewPager.MODE_CARD;
//        cardView.setPreventCornerOverlap(isCard);
//        cardView.setUseCompatPadding(isCard);
        final int img = data.getImg();
        Glide.with(context).load(img).apply(new RequestOptions().error(R.mipmap.pop_invite_bg)).into(imageView);
//        Glide.with(view.getContext()).load(Path.BASE_URL + "/" + UserBean.headimg)
//                .apply(new RequestOptions().error(R.mipmap.head)).into(head);
        ewm.setImageBitmap(Util.encodeAsBitmap(Path.invitereg(UserBean.uid)));
        view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
//                Toast.makeText(context, "data:" + data + "position:" + position, Toast.LENGTH_SHORT).show();
            }
        });
        return view;
    }
}
